package com.mm.cloth.model;

import java.util.Date;

public class TaskStatus {
    public enum Status {
        PENDING("等待处理", "#FF9800"),
        PROCESSING("处理中", "#2196F3"), 
        COMPLETED("已完成", "#4CAF50"),
        FAILED("处理失败", "#F44336");
        
        private final String displayName;
        private final String color;
        
        Status(String displayName, String color) {
            this.displayName = displayName;
            this.color = color;
        }
        
        public String getDisplayName() { return displayName; }
        public String getColor() { return color; }
    }
    
    public enum TaskType {
        MATTING("AI抠图", "ic_matting"),
        FACE_SWAP("AI换脸", "ic_face_swap"),
        CLOTHES_SWAP("AI换衣", "ic_clothes_swap"),
        PHOTO_ENHANCE("照片清晰", "ic_photo_enhance"),
        AI_PAINTING("AI绘画", "ic_ai_painting"),
        PHOTO_RESTORE("老照片修复", "ic_photo_restore"),
        ID_PHOTO("证件照", "ic_id_photo");
        
        private final String displayName;
        private final String iconName;
        
        TaskType(String displayName, String iconName) {
            this.displayName = displayName;
            this.iconName = iconName;
        }
        
        public String getDisplayName() { return displayName; }
        public String getIconName() { return iconName; }
    }
    
    private String taskId;
    private TaskType taskType;
    private Status status;
    private String originalImagePath;
    private String resultImagePath;
    private Date createTime;
    private Date updateTime;
    private int progress; // 0-100
    private String errorMessage;
    private String description;
    
    public TaskStatus() {
        this.taskId = generateTaskId();
        this.createTime = new Date();
        this.updateTime = new Date();
        this.status = Status.PENDING;
        this.progress = 0;
    }
    
    public TaskStatus(TaskType taskType, String originalImagePath) {
        this();
        this.taskType = taskType;
        this.originalImagePath = originalImagePath;
        this.description = "正在处理" + taskType.getDisplayName() + "...";
    }
    
    private String generateTaskId() {
        return "task_" + System.currentTimeMillis() + "_" + (int)(Math.random() * 1000);
    }
    
    // Getters and Setters
    public String getTaskId() { return taskId; }
    public void setTaskId(String taskId) { this.taskId = taskId; }
    
    public TaskType getTaskType() { return taskType; }
    public void setTaskType(TaskType taskType) { this.taskType = taskType; }
    
    public Status getStatus() { return status; }
    public void setStatus(Status status) { 
        this.status = status;
        this.updateTime = new Date();
    }
    
    public String getOriginalImagePath() { return originalImagePath; }
    public void setOriginalImagePath(String originalImagePath) { this.originalImagePath = originalImagePath; }
    
    public String getResultImagePath() { return resultImagePath; }
    public void setResultImagePath(String resultImagePath) { this.resultImagePath = resultImagePath; }
    
    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }
    
    public Date getUpdateTime() { return updateTime; }
    public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
    
    public int getProgress() { return progress; }
    public void setProgress(int progress) { 
        this.progress = progress;
        this.updateTime = new Date();
    }
    
    public String getErrorMessage() { return errorMessage; }
    public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
    
    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }
}
